import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // TODO: 将data的获取转换成vuex形式
    total: 0,
    dataList: [],
    passTime: 0,
  },
  getters: {
    getTotal: state => {
      return state.total
    },
    getDataList: state => {
      return state.dataList
    },
    getPassTime: state => {
      return state.passTime
    },
  },
  mutations: {
    setTotal(state, total) {
      state.total = total
    },
    setDataList(state, dataList) {
      state.dataList = dataList
    },
    setPassTime(state, passTime) {
      state.passTime = passTime
    },
  },
  actions: {
    setTotal(context, total) {
      context.commit('setTotal', total)
    },
    setDataList(context, dataList) {
      context.commit('setDataList', dataList)
    },
    setPassTime(context, passTime) {
      context.commit('setPassTime', passTime)
    },
  },
  modules: {
  }
})
